package com.liwenfeng.diancanspringboot.common.context;

public class BaseContext {

    public static ThreadLocal<String> threadLocal = new ThreadLocal<>();

    public static void setInfo(String info) {
        threadLocal.set(info);
    }

    public static Long getCurrentId() {
        String info = threadLocal.get();
        if (info == null) {
            return null;
        }
        String[] split = info.split("-");
        return Long.valueOf(split[0]);
    }

    public static String getOther() {
        String info = threadLocal.get();
        if (info == null) {
            return null;
        }
        String[] split = info.split("-");
        return split.length == 2 ? split[1] : null;
    }

    public static void removeInfo() {
        threadLocal.remove();
    }

}
